@extends('admin::layouts.master')
@section('title')
    会员列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加','{{route("admin_maintain_create")}}')">
                            <i class="layui-icon"></i>添加分类
                        </button>
                    </div>
                    <div class="layui-card-body " style="overflow-x: auto;">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>一级分类</th>
                                <th>二级分类</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key => $value)
                                <tr>
                                    <td >{{$key+1}}</td>
                                    <td >{{$value['name']}}</td>
                                    <td >
                                        @foreach($value['son'] as $ky => $val)
                                            <div class="layui-col-xs3">
                                                <div class="grid-demo grid-demo-bg1">{{$val['name']}}</div>
                                            </div>
                                        @endforeach
                                    <td style="width:15%">{{$value['created_at']}}</td>
                                    <td class="td-manage" >
                                        <a title="编辑" class="layui-btn"  onclick="xadmin.open('编辑','{{route('admin_maintain_edit',['id'=>$value['id']])}}')" href="javascript:;">
                                            编辑
                                        </a>
                                        <a title="删除" class="layui-btn layui-btn-danger ajax_member_del" data-href="{{route('admin_maintain_delete',['id'=>$value['id']])}}" data-title="确定删除吗？请谨慎操作" href="javascript:;">
                                            删除
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            form.on('switch(switchTest)', function (data) {
                var id = $(this).attr('data-id');
                var status = 1;
                if ($(this).attr('data-status') == 1) {
                    status = 2;
                }
                $.ajax({
                    url: js_url('admin-user-update'),
                    type: 'post',
                    data: {id: id, status: status, '_token': '{{csrf_token()}}'},
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 500, icon: 6}, function () {
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
            });

        })
    </script>
@endsection




